package com.tgsoft.gfrm.modules.sys.test;



import java.time.LocalDate;
import java.util.Date;
import java.util.UUID;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;


import com.tgsoft.gfrm.modules.sys.service.UserService;
import com.tgsoft.gfrm.sys.entity.SysUser;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:spring-context.xml","classpath:spring-context-mybatis.xml" })
public class MyBatisTestBySpringTestFramework {

    //注入userService
    @Autowired
    private UserService userService;
    

    @Test
    public void testAddUser(){
    	
        SysUser user = new SysUser();

        user.setId(UUID.randomUUID().toString().replaceAll("-", ""));
        user.setLoginName("bhxh");
        user.setName("xdp_gacl_白虎神皇");
        user.setPassword("123456");
        user.setCompanyId("01");
        user.setOfficeId("01");
        user.setNo("001");
        user.setCreateBy("1");
        user.setCreateDate(new Date("12/12/2015"));
        user.setRemarks("tamadeya");
        user.setUpdateBy("1");
        user.setUpdateDate(new Date("01/01/2016"));
        user.setDelFlag("0");
        userService.addUser(user);
    }

    
    @Test
    public void testGetUserById(){
        String userId = "13";
        SysUser user = userService.getUserById(userId);
        System.out.println(user.getName());
    }
    
    @Test
    public void findUserByLoginname(){
        String userLoginname = "jn_admin";
        SysUser user = userService.findByLoginName(userLoginname);
        System.out.println(user.getName());
    }
}